package day14.KeJian;

public class MyThread01 extends Thread{
    MyThread01(){}
    MyThread01(String name){
        super(name);
    }

    @Override
    public void run() {
        for (int i = 0; i < 100; i++) {
            System.out.println(getName()+":"+i);

        }
    }
}
class MyThreadDemo01{
    public static void main(String[] args) {
        MyThread01 my1 = new MyThread01();
        MyThread01 my2 = new MyThread01();
        //void setName(String name)：将此线程的名称更改为等于参数 name
        my1.setName("789");
        my2.setName("951");
        //Thread(String name)
        MyThread01 mt1 = new MyThread01("123");
        MyThread01 mt2 = new MyThread01("456");
        //static Thread currentThread() 返回对当前正在执行的线程对象的引用
        mt1.start();
        mt2.start();
        //static Thread currentThread() 返回对当前正在执行的线程对象的引用
        System.out.println(Thread.currentThread().getName());
    }
}